package com.mycompany.app.common.scheduler.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import com.mycompany.app.common.entity.ToStringEntity;

/**
 * check daemon job(unsync report, daemon system job) status.
 * 
 * @author Shawn.guo
 */

@Entity
@Table(name = "daemon_log")
public class DaemonLog extends ToStringEntity {

    public static enum TaskStatus {
        UNDEFINED, PROCESSING, SUCCESSFUL, FAILED
    };

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @ManyToOne
    @JoinColumn(name = "daemon_job_id")
    private DaemonJob daemonJob;

    @Column(name = "scheduled_time")
    private java.util.Date scheduledTime;

    @Column(name = "start_time")
    private java.util.Date startTime;

    @Column(name = "end_time")
    private java.util.Date endTime;

    @Enumerated(EnumType.STRING)
    private TaskStatus status;

    private java.lang.String description;

    // ========================================================

    @Override
    public String toString() {

        return ToStringBuilder.reflectionToString(this,
                ToStringStyle.SHORT_PREFIX_STYLE);
    }

    // ========================================================

    public Long getId() {

        return id;
    }

    public void setId(Long id) {

        this.id = id;
    }

    public DaemonJob getDaemonJob() {

        return daemonJob;
    }

    public void setDaemonJob(DaemonJob daemonJob) {

        this.daemonJob = daemonJob;
    }

    public java.util.Date getScheduledTime() {

        return scheduledTime;
    }

    public void setScheduledTime(java.util.Date scheduledTime) {

        this.scheduledTime = scheduledTime;
    }

    public java.util.Date getStartTime() {

        return startTime;
    }

    public void setStartTime(java.util.Date startTime) {

        this.startTime = startTime;
    }

    public java.util.Date getEndTime() {

        return endTime;
    }

    public void setEndTime(java.util.Date endTime) {

        this.endTime = endTime;
    }

    public TaskStatus getStatus() {

        return status;
    }

    public void setStatus(TaskStatus status) {

        this.status = status;
    }

    public java.lang.String getDescription() {

        return description;
    }

    public void setDescription(java.lang.String description) {

        this.description = description;
    }

}
